package com.guo.hui.eurekaconsumer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @ClassName HelloController
 * @Description TODO
 * @Author zhengguohui
 * @Date 2018/7/17 20:03
 */

@RestController
public class HelloController {


    @Autowired
    RestTemplate restTemplate;

    @GetMapping("/ribbon")
    public String ribbon(String name) {
        return restTemplate.getForObject("http://eureka-demo/hello?name=" + name, String.class);

    }
//    @Autowired
//    LoadBalancerClient load;
//    @GetMapping("/consumer")
//    public String consumer() {
//        ServiceInstance service = load.choose("eureka-client");
//        String url = "http://" + service.getHost() + ":" + service.getPort() + "/hello?name=ceshi";
//        System.out.println(url);
//        return restTemplate.getForObject(url, String.class);
//
//    }


}
